package com.huazai.juc.cec.thread.july.thirtyOne;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.extern.slf4j.Slf4j;

/**
 * @author Seon
 * @date 2022/7/31 17:02
 */
@Slf4j
@Data
@AllArgsConstructor
@NoArgsConstructor
public class TicketWindow {
    private int count;
    public synchronized int sell(int count) {
        if (this.count >= count) {
            this.count -= count;
            return count;
        } else {
            return 0;
        }
    }
}
